package cn.xzz.pethome.emp.service.impl;

import cn.xzz.pethome.dept.domain.Department;
import cn.xzz.pethome.emp.domain.Employee;
import cn.xzz.pethome.emp.mapper.EmployeeMapper;
import cn.xzz.pethome.emp.query.EmpQuery;
import cn.xzz.pethome.emp.service.IEmpService;
import cn.xzz.pethome.share.utils.PageCount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmpServiceImpl implements IEmpService {
    @Autowired
    private EmployeeMapper empmapper;

    @Override
    public PageCount<Employee> getPageCount(EmpQuery query) {
        PageCount<Employee> empPageCount = new PageCount<>();
        empPageCount.setCount(empmapper.findcount(query));
        empPageCount.setDeptlist(empmapper.findAll(query));
        return empPageCount;
    }

    @Override
    public Employee findById(Long id) {
        return empmapper.findById(id);
    }

    @Override
    public void addemp(Employee employee) {
        empmapper.addemp(employee);
    }

    @Override
    public void updateemp(Employee employee) {
        empmapper.updateemp(employee);
    }

    @Override
    public void delete(Long id) {
        empmapper.delete(id);
    }

    @Override
    public void batchdeleteemp(List<Long> ids) {
        empmapper.batchdeleteemp(ids);
    }

    @Override
    public List<Employee> findempall() {
        return empmapper.findempall();
    }
}
